<?php
/**
 * Controller de Publica.
 *
 *
 * @filesource          
 * @copyright		
 * @link		http://www.pragmatia.com Pragmatia
 * @package		datagro
 * @subpackage	app.controllers
 * @version     1.1
 * @license		http://www.opensource.org/licenses/mit-license.php The MIT License
 * @author      Martin Radosta <mradosta@pragmatia.com>
 */

/**
 * Clase PublicaController
 *
 * @package	    datagro
 * @subpackage	app.controllers
 */

class PublicaController extends AppController
{
    var $name = 'Publica';
    var $uses = null;
	var $components = array('Mailer');
	
	function index() {
		$this->layout = 'publica';
	}
   
	function quienes_somos() {
		$this->layout = 'publica';
	}
   
	function nuestras_marcas() {
		$this->layout = 'publica';
	}
   
	function contactenos() {
		if(!empty($this->data)) {
		
			$html=false;
			$html= "<html>";
			$html.= "<body>";
			$html.= "<b>Formulario de contacto desde la Web</b><br>";
			$html.= "<b>Nombre:</b>" . $this->data['Publica']['nombre'];
			$html.= "<br><b>Apellido:</b>" . $this->data['Publica']['apellido'];
			$html.= "<br><b>Empresa:</b>" . $this->data['Publica']['empresa'];
			$html.= "<br><b>Localidad:</b>" . $this->data['Publica']['localidad'];
			$html.= "<br><b>Email:</b>" . $this->data['Publica']['email'];
			$html.= "<br><b>Consulta:</b>" . $this->data['Publica']['consulta'];
			$html.= "</body>";
			$html.= "</html>";
			
			$this->Mailer->From = "postmaster@datagro.com.ar";
			$this->Mailer->Sender = "postmaster@datagro.com.ar";

			$this->Mailer->FromName = "Contacto - DataAgro";
			$this->Mailer->AddAddress($this->data['Publica']['seleccion']);
			$this->Mailer->Subject = "Contacto Web";
			$this->Mailer->Body = $html;
			$this->Mailer->IsHTML (true);

			$this->Mailer->IsSMTP( true );
			$this->Mailer->Host     = "127.0.0.1";
			//$this->Mailer->Host     = "201.216.195.9";
			$this->Mailer->Mailer   = "smtp";

			$this->Mailer->SMTPAuth = true;
			$this->Mailer->Username = 'postmaster@datagro.com.ar';
			$this->Mailer->Password = 'data8877';
			$this->Mailer->send();
			$this->Session->setFlash('Su contacto ha sido enviado.');
		}
		$this->layout = 'publica';
	}

	function aplicacion() {
		$this->layout = 'publica';
	}

	function faq() {
		loadModel("Faq");
		$faq = new Faq();
		$this->set("faqs", $faq->findAll());
		$this->layout = 'publica';
	}
}
   
?>